<template>
  <div class="legendContainer" v-if="isLegendShow" v-drag>
    <div class="legendDialogTitle drag-handle">
      <div class="title-left">
        <div class="bar"></div>
        <div class="title-text">地图图例</div>
      </div>
      <div class="title-right">
        <!-- <div  tabindex="0" class="icon">-</div> -->
        <div tabindex="0" class="icon" @click="closeDialog">×</div>
      </div>
    </div>
    <div class="legendDialogContent">
      <img src="../../../assets/legend/legend.png" alt="地图图例" />
    </div>
  </div>
</template>

<script>
export default {
  props: {
    dialogVisible: {
      type: Boolean,
      required: true,
    },
  },
  methods: {
    closeDialog() {
      this.$store.commit('setMapLegendShow',false)
    },
  },
  computed: {
    isLegendShow() {
      // 返回 prop 的值
      return this.dialogVisible;
    },
  },
};
</script>

<style lang="scss" scoped>
.legendContainer {
  width: 20vw;
  color: white;
  position: absolute;
  top: 10vh;
  right: 1vw;

  height: 46vh;
  z-index: 2;
  .legendDialogTitle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    font-size: 1rem;
    background-color: #285383;
    .title-left,
    .title-right {
      display: flex;
      align-items: center;
    }
    .bar {
      width: 5px; /* 小竖条的宽度 */
      height: 20px; /* 小竖条的高度 */
      background-color: white; /* 小竖条的颜色 */
      margin-right: 10px; /* 小竖条和文字之间的间距 */
    }
    .icon {
      width: 20px; /* 小方框的宽度 */
      height: 20px; /* 小方框的高度 */
      // border: 1px solid #4998f2; /* 小方框的边框 */
      margin-left: 5px; /* 小方框之间的间距 */
    }
    .icon:hover {
      color: #4998f2;
    }
    .icon:focus {
      color: #4998f2;
    }
  }
  .legendDialogContent {
    padding: 10px;
    display: flex;
    flex-direction: column;
    background-color: #285383;
    font-size: 0.8rem;
    img {
      height: 45vh;
    }
  }
}
</style>
